The philosophy of Natural Syntax argues that user-defined types should behave as first-class citizens. By implementing operator overloading, we allow classes to use standard notation (like + or ==), which reduces cognitive load and fulfills the principle of least astonishment.
1. Anatomy & Dispatch
An operator is a function with a special name: the keyword operator followed by a symbol. A unary operator has one operand, while a binary operator has two. When defined as a member function, the left-hand operand binds to the implicit this pointer (a.operator+(b)). As a nonmember, both are explicit (operator+(a, b)).
2. Constraints & Ethics
C++ prevents "language vandalism": you cannot create new symbols (e.g., **) or redefine operations for built-in types (e.g., int + int). Precedence and associativity are immutable. Architecture principle: Classes defining == integrate effortlessly with library algorithms like std::find.